/* ---------------------------------------------------------------------- */
/* Script generated with: DeZign for Databases v4.1.3                     */
/* Target DBMS:           MS SQL Server 2005                              */
/* Project file:          De thi.dez                                      */
/* Project name:                                                          */
/* Author:                                                                */
/* Script type:           Database creation script                        */
/* Created on:            2011-04-29 14:26                                */
/* ---------------------------------------------------------------------- */

CREATE DATABASE DETHI
GO
USE DETHI
GO
/* ---------------------------------------------------------------------- */
/* Tables                                                                 */
/* ---------------------------------------------------------------------- */

/* ---------------------------------------------------------------------- */
/* Add table "ChucVu"                                                     */
/* ---------------------------------------------------------------------- */

CREATE TABLE [ChucVu] (
    [ID] INTEGER IDENTITY(0,1) NOT NULL,
    [Ten_chuc_vu] NVARCHAR(50),
    [Ghi_chu] NVARCHAR(200),
    [Ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_ChucVu] PRIMARY KEY ([ID])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "ThanhVien"                                                  */
/* ---------------------------------------------------------------------- */

CREATE TABLE [ThanhVien] (
    [ID] INTEGER IDENTITY(0,1) NOT NULL,
    [Ten_dang_nhap] NVARCHAR(40),
    [Mat_khau] NVARCHAR(40),
    [Ho_ten] NVARCHAR(100),
    [Ngay_sinh] DATETIME,
    [Gioi_tinh] NVARCHAR(5),
    [Dia_chi] NVARCHAR(200),
    [So_dien_thoai] NVARCHAR(40),
    [Ma_chuc_vu] NVARCHAR(40),
    [Ma_KH] INTEGER,
    [Ghi_chu] NVARCHAR(200),
    [Ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_ThanhVien] PRIMARY KEY ([ID])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "MonHoc"                                                     */
/* ---------------------------------------------------------------------- */

CREATE TABLE [MonHoc] (
    [Ma_MH] NVARCHAR(40) NOT NULL,
    [Ten_MH] NVARCHAR(50),
    [So_tin_chi] INTEGER,
    [Hoc_phi] INTEGER,
    [Ghi_chu] NVARCHAR(200),
    [Ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_MonHoc] PRIMARY KEY ([Ma_MH])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "KhoaHoc"                                                    */
/* ---------------------------------------------------------------------- */

CREATE TABLE [KhoaHoc] (
    [ID] INTEGER IDENTITY(0,1) NOT NULL,
    [Ten_KH] NVARCHAR(50),
    [Ngay_bat_dau] DATETIME,
    [Ngay_ket_thuc] DATETIME,
    [Ghi_chu] NVARCHAR(200),
    [Ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_KhoaHoc] PRIMARY KEY ([ID])
)
GO

/* ---------------------------------------------------------------------- */
/* Add table "DangKyMonHoc"                                               */
/* ---------------------------------------------------------------------- */

CREATE TABLE [DangKyMonHoc] (
    [Ma_MH] NVARCHAR(40) NOT NULL,
    [Ma_SV] NVARCHAR(40) NOT NULL,
    [Ghi_chu] NVARCHAR(200),
    [Ngay_cap_nhat_cuoi] DATETIME,
    CONSTRAINT [PK_DangKyMonHoc] PRIMARY KEY ([Ma_MH], [Ma_SV])
)
GO

/* ---------------------------------------------------------------------- */
/* Foreign key constraints                                                */
/* ---------------------------------------------------------------------- */
/*
ALTER TABLE [ThanhVien] ADD CONSTRAINT [ChucVu_ThanhVien] 
    FOREIGN KEY ([Ma_chuc_vu]) REFERENCES [ChucVu] ([ID])
GO

ALTER TABLE [ThanhVien] ADD CONSTRAINT [KhoaHoc_ThanhVien] 
    FOREIGN KEY ([Ma_KH]) REFERENCES [KhoaHoc] ([ID])
GO

ALTER TABLE [DangKyMonHoc] ADD CONSTRAINT [ThanhVien_DangKyMonHoc] 
    FOREIGN KEY ([Ma_SV]) REFERENCES [ThanhVien] ([Ten_dang_nhap])
GO

ALTER TABLE [DangKyMonHoc] ADD CONSTRAINT [MonHoc_DangKyMonHoc] 
    FOREIGN KEY ([Ma_MH]) REFERENCES [MonHoc] ([Ma_MH])
GO
*/